package com.yesep.learn.design.creational.builder;

import com.yesep.learn.design.common.pojo.*;
import com.yesep.learn.design.common.util.*;

public class Director {
    private ComputerBuilder computerBuilder;

    public Director(ComputerBuilder computerBuilder) {
        this.computerBuilder = computerBuilder;
    }

    public Director(Class<? extends ComputerBuilder> cls) throws Exception {
        this.computerBuilder = Util.getInstance(cls);
    }

    public Computer constructComputer() {
        computerBuilder.buildComputer();
        computerBuilder.buildModel();
        computerBuilder.buildMaster();
        computerBuilder.buildAudio();
        computerBuilder.buildKeyboard();
        computerBuilder.buildMouse();
        computerBuilder.buildScreen();
        return computerBuilder.getComputer();
    }
}
